package com.atguigu.edu.realtime.util;

import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.common.time.Time;
import org.apache.flink.streaming.api.CheckpointingMode;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class EnvAndCheckUtils {
    public static StreamExecutionEnvironment getEnvAndMarkCheck(){
        //1 创建环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(4);
        //2 设置检查点
        env.enableCheckpointing(5000L);
//        env.getCheckpointConfig().setCheckpointTimeout(500000L);
//        env.getCheckpointConfig().setExternalizedCheckpointCleanup(CheckpointConfig.ExternalizedCheckpointCleanup.DELETE_ON_CANCELLATION);
//        env.getCheckpointConfig().setMinPauseBetweenCheckpoints(500L);
          env.setRestartStrategy(RestartStrategies.failureRateRestart(5, Time.days(30),Time.seconds(5)));
//        env.getCheckpointConfig().setCheckpointStorage("hdfs://hadoop102:8020/edu/ck");
//        System.setProperty("HADOOP_USER_NAME","atguigu");
        return env;

    }
}
